//
// Created by wxd on 2025/7/13.
//

#include <iostream>

#include "../wrapper/log/Logger.h"
#include "../wrapper/monitor/GLDebug.hpp"
#include "../global/ChineseOutput.hpp"
#include "../global/EngineDataProperties.h"

#include "../application/app/Application.h"


using namespace std;

// 日志初始化
inline void initLog() {
    Logger::getInstance().init(LogLevel::DEBUG, "", true, false);
}

inline void onResize(int w, int h) {
    glViewport(0, 0, w, h);
    std::cout << "w: " << w << " h: " << h << std::endl;
}

inline void onKeyBoard(int key, int action, int mods) {
    std::cout << "key: " << key << " action: " << action << " mods: " << mods << std::endl;
}

inline void onMouseMove(double x, double y) {
    std::cout << x << ", " << y << std::endl;
}

inline void onMouseButton(int button, int action, int mods) {
    std::cout << "button: " << button << " action: " << action << " mods: " << mods << std::endl;
}

inline void onScroll(double xOffset, double yOffset) {
    std::cout << xOffset << ", " << yOffset << std::endl;
}

inline void tuple_demo() {
    std::tuple<GLuint, GLuint, GLuint> shader = { 1, 2, 3 };
    std::get<0>(shader);
}
/**
 * 引擎的测试代码
 * @return
 */
inline int render() {
    initLog();

    // 解决日志输出中文乱码问题
    ChineseOutput::init();

    LOG_DEBUG_METHOD("", "你好，世界");
    LOG_DEBUG_METHOD("", "你好，OpenGL");

    std::cout << _FLOAT_SIZE << std::endl;
    std::cout << _VEC3_SIZE << std::endl;
    std::cout << _MAT4_SIZE << std::endl;

    EngineApp.initDefaultWindowConfig();
    EngineApp.setResizeCallback(onResize);
    EngineApp.setKeyBoardCallback(onKeyBoard);
    EngineApp.setCursorCallback(onMouseMove);
    EngineApp.setMouseCallback(onMouseButton);
    EngineApp.setMouseScrollCallback(onScroll);
    EngineApp.init();

    while (EngineApp.update()) {
        GL_CALL(glClear(GL_COLOR_BUFFER_BIT))
    }

    EngineApp.destroy();
    return 0;
}